<template>
    <div class="tuijian">
        <h2>推荐</h2>
        <ul>
            <template v-if="recom_list.rc_id === undefined">
                还没有推荐哦~
            </template>
            <template v-else>
                <li v-for="(t,index) in recom_list" :key="index"><a
                    :href="t.recom_url">{{t.recom_title}}</a>
                </li>
            </template>
        </ul>
    </div>
</template>

<script>
    import {getHot} from "../service/getData";

    export default {
        name: "recommend",
        data() {
            return {
                recom_list: [
                    {
                        rc_id: "1",
                        recom_title: "标题1",
                        recom_url: "www.baidu.com"
                    }
                ],
                total: 1,
                currval: 1,
            }
        },
        methods: {
            get_recom: function () {
                //这里的res，是resolve返回的，所以是(res)返回参数，不像以往的response => {}
                //this.$get(API.recomUrl).then((res) => {
                //    this.recom_list = res.data.recomList;
                //})
                getHot(this.currval).then((res) => {
                    this.recom_list = res.data.content;
                    this.total = res.data.total;
                })
            }
        },
        mounted() {
            this.get_recom();
        }
    }
</script>
